package com.wbao.dianniu.update;

import java.util.LinkedList;

/**
 * Created by yejianjun on 2018/6/3.
 */

public class ChatUnreadChangeManger {

    private static LinkedList<IUnreadChangeListener> mListener;
    private static ChatUnreadChangeManger instance;

    public static ChatUnreadChangeManger getInstance() {
        if (null == instance) {
            mListener = new LinkedList<IUnreadChangeListener>();
            instance = new ChatUnreadChangeManger();
        }
        return instance;
    }

    private ChatUnreadChangeManger() {
    }

    public interface IUnreadChangeListener {

        public void unreadChange(int idType);

        // 增加所有通知未读
        public void addAllNotifyUnread(int counts);

        // 减去所有通知未读
        public void minusAllNotifyUnread(int counts);

        // 增加所有消息未读
        public void addAllChatUnread(int counts);

        // 减去所有消息未读
        public void minusAllChatUnread(int counts);

        // 设置消息未读数
        public void setChatUnread(int counts);

        // 设置通知未读数
        public void setNofifyUnread(int counts);

    }

    public void addUnreadChangeListener(IUnreadChangeListener listener) {
        mListener.add(listener);
    }

    public void removeUnreadChangeListener(IUnreadChangeListener listener) {
        mListener.remove(listener);
    }

    public void chatUnreadChange(int idType, int couts) {
        for (int i = 0; i < mListener.size(); i++) {
            mListener.get(i).unreadChange(idType);
        }
    }

    public void addNotifyUnread(int count) {
        for (int i = 0; i < mListener.size(); i++) {
            mListener.get(i).addAllNotifyUnread(count);
        }
    }

    public void addChatUnread(int count) {
        for (int i = 0; i < mListener.size(); i++) {
            mListener.get(i).addAllChatUnread(count);
        }
    }

    /**
     * 减去通知未读数
     *
     * @param count
     */
    public void minusNotifyUnread(int count) {
        for (int i = 0; i < mListener.size(); i++) {
            mListener.get(i).minusAllNotifyUnread(count);
        }
    }

    /**
     * 减去通知未读数
     *
     * @param count
     */
    public void minusChatUnread(int count) {
        for (int i = 0; i < mListener.size(); i++) {
            mListener.get(i).minusAllChatUnread(count);
        }
    }

    public void setNofifyUnread(int count) {
        for (int i = 0; i < mListener.size(); i++) {
            mListener.get(i).setNofifyUnread(count);
        }
    }

    public void setChatUnread(int count) {
        for (int i = 0; i < mListener.size(); i++) {
            mListener.get(i).setChatUnread(count);
        }
    }


}
